package com.erp.erp_servers.Purchase.imp;

import com.erp.erp_dao.Purchase.IPurchaseProductDAO;
import com.erp.erp_entitys.Purchase.ExportVo;
import com.erp.erp_entitys.Purchase.PurchaseProduct;
import com.erp.erp_entitys.Purchase.TaskVo;
import com.erp.erp_servers.Purchase.IPurchaseProductService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.Map;

@Service
public class ImpPurchaseProductService implements IPurchaseProductService {

    @Autowired
    private IPurchaseProductDAO productDAO;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return productDAO.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(PurchaseProduct record) {
        return productDAO.insert(record);
    }

    @Override
    public int insertSelective(PurchaseProduct record) {
        return productDAO.insertSelective(record);
    }

    @Override
    public PurchaseProduct selectByPrimaryKey(Integer id) {
        return productDAO.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(PurchaseProduct record) {
        return productDAO.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(PurchaseProduct record) {
        return productDAO.updateByPrimaryKey(record);
    }

    @Override
    public int updateProValidByProList(List<PurchaseProduct> proList) {
        return productDAO.updateProValidByProList(proList);
    }

    @Override
    public List<PurchaseProduct> selectProductByPuId(Integer puId) {
        return productDAO.selectProductByPuId(puId);
    }

    @Override
    public int deleteByIdList(List<Integer> idList) {
        return productDAO.deleteByIdList(idList);
    }

    @Override
    public PageInfo<ExportVo> selectExportByList(ExportVo vo) {
        List<ExportVo> list = productDAO.selectExportByList(vo);
        PageInfo pageInfo = new PageInfo(list);
        if(!CollectionUtils.isEmpty(list)){
            pageInfo.setList(list);
            return pageInfo;
        }
        return pageInfo;
    }

    @Override
    public PageInfo<PurchaseProduct> selectExportProductByExIds(List<Integer> idList) {
        List<PurchaseProduct> list = productDAO.selectExportProductByExIds(idList);
        PageInfo pageInfo = new PageInfo(list);
        if(!CollectionUtils.isEmpty(list)){
            pageInfo.setList(list);
            return pageInfo;
        }
        return pageInfo;
    }

    @Override
    public int upExportProductNum(Map<String, Object> map){
        return productDAO.upExportProductNum(map);
    }

    @Override
    public PageInfo<PurchaseProduct> selectExportProductPartByCode(String productCode, String productGgCode){
        List<PurchaseProduct> list = productDAO.selectExportProductPartByCode(productCode, productGgCode);
        PageInfo pageInfo = new PageInfo(list);
        if(!CollectionUtils.isEmpty(list)){
            pageInfo.setList(list);
            return pageInfo;
        }
        return pageInfo;
    }

    @Override
    public PageInfo<TaskVo> selectTaskByList(TaskVo vo) {
        List<TaskVo> list = productDAO.selectTaskByList(vo);
        PageInfo pageInfo = new PageInfo(list);
        if(!CollectionUtils.isEmpty(list)){
            pageInfo.setList(list);
            return pageInfo;
        }
        return pageInfo;
    }

    @Override
    public PageInfo<PurchaseProduct> selectTaskProductByTaskIds(List<Integer> idList) {
        List<PurchaseProduct> list = productDAO.selectTaskProductByTaskIds(idList);
        PageInfo pageInfo = new PageInfo(list);
        if(!CollectionUtils.isEmpty(list)){
            pageInfo.setList(list);
            return pageInfo;
        }
        return pageInfo;
    }

    @Override
    public PageInfo<PurchaseProduct> selectExportPartByExportIds(List<Integer> idList) {
        List<PurchaseProduct> list = productDAO.selectExportPartByExportIds(idList);
        PageInfo pageInfo = new PageInfo(list);
        if(!CollectionUtils.isEmpty(list)){
            pageInfo.setList(list);
            return pageInfo;
        }
        return pageInfo;
    }

    @Override
    public PageInfo<PurchaseProduct> selectTaskPartByTaskIds(List<Integer> idList) {
        List<PurchaseProduct> list = productDAO.selectTaskPartByTaskIds(idList);
        PageInfo pageInfo = new PageInfo(list);
        if(!CollectionUtils.isEmpty(list)){
            pageInfo.setList(list);
            return pageInfo;
        }
        return pageInfo;
    }
}
